package mysql

import "gorm.io/gorm"

type Order struct {
	gorm.Model
	OrderSn    string  `gorm:"type:char(36);not null;unique;comment:订单号"`
	UserId     int     `gorm:"type:int(11);not null;index;comment:用户id"`
	Amount     float64 `gorm:"type:decimal(10,2);not null;comment:订单金额"`
	Status     int     `gorm:"type:tinyint(1);default:0;comment:订单状态:0未支付,1已支付,2已取消,3已退款,4已完成"`
	Payment    int     `gorm:"type:tinyint(1);not null;comment:支付方式:0微信,1支付宝,2银行卡,3余额"`
	GoodsTitle string  `gorm:"type:varchar(100);not null;comment:商品标题"`
	GoodsPrice float64 `gorm:"type:decimal(10,2);not null;comment:商品价格"`
	GoodsId    int     `gorm:"type:int(11);not null;comment:商品id"`
	GoodsCover string  `gorm:"type:varchar(200);not null;comment:商品封面"`
}

func (o *Order) AddOrder() error {
	return DB.Create(&o).Error
}
